<?php

namespace app\admin\controller;

class SystemUpgrade
{
    /**
     *  升级检测页面
     */
    public function index()
    {
        $data = array();
        $data["rowData"] = app("L_Common_version")->info();
        $data["request"] = request()->param();
        return view("admin/systemUpgrade/index", $data);
    }

    /**
     *  安装
     */
    public function install()
    {
        //获取下载文件列表
        $response = app("C_Admin_system_upgrade")->getDownFile();
        $listData = array();
        if ($response["success"]) {
            $listData = $response["data"];
        }
        $data = array();
        $data["listData"] = $listData;
        $data["request"] = request()->param();
        return view("admin/systemUpgrade/install", $data);
    }

    /**
     *  下载压缩包
     */
    public function download()
    {
        //获取下载文件列表
        $response = app("C_Admin_system_upgrade")->getDownFile();
        $listData = array();
        if ($response["success"]) {
            $listData = $response["data"];
        }
        $data = array();
        $data["listData"] = $listData;
        $data["request"] = request()->param();
        return view("admin/systemUpgrade/download", $data);
    }

    /**
     * 下载文件
     */
    public function downloadFile()
    {
        $result = app("C_Admin_system_upgrade")->downloadFile();
        return jsonResponse($result);
    }

    /**
     * 安装文件
     */
    public function installFile()
    {
        $result = app("C_Admin_system_upgrade")->installFile();
        return jsonResponse($result);
    }

    /**
     * 安装脚本
     */
    public function execScript()
    {
        $result = app("C_Admin_system_upgrade")->execScript();
        return jsonResponse($result);
    }

    /**
     * 更新key
     * @return mixed
     */
    public function updateKey()
    {
        $result = app("C_Admin_system_upgrade")->updateKey();
        return jsonResponse($result);
    }

    /**
     * 更新key
     * @return mixed
     */
    public function updateWhiteList()
    {
        $result = app("C_Admin_system_upgrade")->updateWhiteList();
        return jsonResponse($result);
    }

}